﻿#include "Enemy3.h"
#include "GameUtil.h"

using namespace cocos2d;

Enemy3::Enemy3(void)
{
}


Enemy3::~Enemy3(void)
{
}

bool Enemy3::init(){  
    if (!Enemy::init()) {  
        return false;  
    }  

	// init
	d_creatureSprite->initWithFile("e3.png");

	d_maxHP = 120;
	d_speed = 90;
	d_shootInterval = 500;
	d_stopPos = 45;
	d_bulletSpeed = 100;
	d_bulletDamage = 2;
	d_bulletType = BULLET_TYPE_6;

    return true;  
}

CCAction* Enemy3::getWalkAction(){
    CCActionInterval*  actionBy = CCScaleBy::create(1.0f, 0.9f, 1.1f);
	CCAction* act = CCRepeatForever::create(CCSequence::create(actionBy, actionBy->reverse(), NULL));
	return act;
}

void Enemy3::shoot(float dt)
{
	float interval = 30;
	unsigned int count = 5 - 1;

	interval = GameUtil::instance()->getSetting()->getShootInterval(interval, this);
	this->schedule(schedule_selector(Enemy3::shootOne), interval, count, 0);
}

void Enemy3::shootOne(float dt) {

	BulletManager* bulletManager = GameUtil::instance()->getBulletManager();

	bulletManager->shoot(this, 0);
}

void Enemy3::stopShoot()
{
	this->unschedule(schedule_selector(Enemy3::shootOne));
	Enemy::stopShoot();
}